package nz.ac.massey.cs.sdc.log4jassignment.s09007369;

import java.io.OutputStreamWriter;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.FileAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Logger LOG = Logger.getLogger("test");
			
			MemoryAppender memoryAppender = new MemoryAppender();
			LOG.addAppender(memoryAppender);		
			for(long i = 0; i<500000; i++)
				LOG.info("message "+i);
		
					
			ConsoleAppender consoleAppender = new ConsoleAppender();
			consoleAppender.setWriter(new OutputStreamWriter(System.out));
			consoleAppender.setLayout(new StringTemplateLayout("<l> <m>"));
			LOG.addAppender(consoleAppender);		
			for(long i = 0; i<500000; i++)
				LOG.info("message "+i);
		/*	
			ConsoleAppender consoleAppender = new ConsoleAppender();
			consoleAppender.setWriter(new OutputStreamWriter(System.out));
			consoleAppender.setLayout(new PatternLayout("%p %m"));
			LOG.addAppender(consoleAppender);		
			for(long i = 0; i<500000; i++)
				LOG.info("message "+i);
		*/	
	/*
			FileAppender fileAppender = new FileAppender();		
			fileAppender.setWriter(new OutputStreamWriter(System.out));
			fileAppender.setLayout(new StringTemplateLayout("<l> <m>"));
			LOG.addAppender(fileAppender);
			for(long i = 0; i<500000; i++)
				LOG.info("message "+i);
		*	
			FileAppender fileAppender = new FileAppender();		
			fileAppender.setWriter(new OutputStreamWriter(System.out));
			fileAppender.setLayout(new PatternLayout("%p %m"));
			LOG.addAppender(fileAppender);
			for(long i = 0; i<500000*2; i++)
				LOG.info("message "+i);
				
		/*	
			FileAppender fileAppender3 = new FileAppender();		
			fileAppender3.setWriter(new OutputStreamWriter(System.out));
			fileAppender3.setLayout(new StringTemplateLayout("<l> <m>"));
			LOG.addAppender(fileAppender3);
			for(long i = 0; i<500000; i++)
				LOG.info("message "+i);
				*/
	}

}
